Why am I getting a 'list index out of range' error in my Python mode calculation code